<?php
/* ----------------------------------------------------------
--               JacoCMS by Jaco Ruit                      --
-------------------------------------------------------------
--     JacoCMS is Open Source and is lincenced under       --
--             GNU General Public Licence v3               --
--          http://www.gnu.org/copyleft/gpl.html           --
-------------------------------------------------------------
--       Please don't remove any text from the footers.    --
-------------------------------------------------------------
-- Credits:   * Jaco Ruit          ~     Scripts,MySQL     --     
-----------------------------------------------------------*/

# JacoCMS Analytics Class

#includes
include 'includes/Browser.php';

class Analytics
{
	public function logVisitor()
	{
		$timestampsec = $_SERVER['REQUEST_TIME'];
		$datetime= date("Y-m-d H:i:s", $timestampsec);
		$browser = new Browser();
		$thebrowser = $browser->getBrowser();
		$theplatform = $browser->getPlatform();
		$page = $this->getURL();
		$ip=$_SERVER['REMOTE_ADDR'];
		if ($thebrowser == 'unknown')
		{
			return;
		}

		$query = "INSERT INTO visitors (IP, Date, Page, Browser, Platform) VALUES ('" . $ip . "','" . $datetime . "','" . $page . "','" . $thebrowser . "','" . $theplatform ."')";
		$result = mysql_query($query);
	}
	
	function getURL()
	{
		$pageURL = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
		return $pageURL;
	}
}
